page.tsx 817 B

1234567891011121314151617181920212223242526272829303132
  1. import { notFound } from 'next/navigation';
  2. import { fetchJson } from '@/lib/utils/server';
  3. import { ResultDto } from '@/types/response/common';
  4. import { ChannelDetail } from '@/types/channel';
  5. type Props = {
  6. params: Promise<{ identifier: string }>;
  7. };
  8. export default async function ChannelIntroPage({ params }: Props)
  9. {
  10. const { identifier } = await params;
  11. const res: ResultDto<ChannelDetail> = await fetchJson(`/api/channel/${encodeURIComponent(decodeURIComponent(identifier))}`, {
  12. method: 'GET'
  13. });
  14. if (!res.data) {
  15. notFound();
  16. }
  17. const ch = res.data;
  18. return (
  19. <div className="channel-page__tab-content">
  20. {ch.description ? (
  21. <p className="channel-page__description">{ch.description}</p>
  22. ) : (
  23. <p className="channel-page__empty">채널 소개가 없습니다</p>
  24. )}
  25. </div>
  26. );
  27. }